package com.greenline.push.home.controllers.classbatch;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.greenline.guser.annotation.GuserResource;
import com.greenline.push.common.json.GridJsonData;
import com.greenline.push.core.pushcenter.ClassBatchDefineManager;
import com.greenline.push.dal.pushcenter.dataobject.ClassBatchDefineDO;
import com.greenline.push.dal.query.ClassBatchDefineQuery;

@Controller
@RequestMapping(value = "/batch")
public class ClassBatchController {

	@Autowired
	private ClassBatchDefineManager batchManager;
	
	@GuserResource("用户分组列表")
	@RequestMapping(value = "/query.json", method = RequestMethod.GET)
	@ResponseBody
	public GridJsonData<ClassBatchDefineDO> listRecord(ModelMap model,
			@ModelAttribute("classBatchDefine") ClassBatchDefineQuery query,
			@RequestParam(value = "page", defaultValue = "1", required = false) String pageIndex,
			@RequestParam(value = "pageSize", defaultValue = "10", required = false) String pageSize) {
		query.setPageIndex(Integer.parseInt(pageIndex));
		query.setPageSize(Integer.parseInt(pageSize));
		GridJsonData<ClassBatchDefineDO> ret = new GridJsonData<ClassBatchDefineDO>();
		ret.setQuery(batchManager.listByQuery(query));
		return ret;
	}
}
